package cz.su.pod.reservation.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Reservation {
	@Id @GeneratedValue(strategy = GenerationType.AUTO) private int id;
	@ManyToOne private User requestor;
	@OneToOne private ReservedObject reservedObject;
	@OneToMany private List<ReservationContext> reservationContexts; 
	@Temporal(TemporalType.TIMESTAMP) @Column(name = "fromDate", nullable = false) private Date from;
	@Temporal(TemporalType.TIMESTAMP) @Column (name = "toDate", nullable = false) private Date to;	
	@Column(nullable = true) private String description;
	
	public Reservation() {
		// TODO Auto-generated constructor stub
	}
		
	public Reservation(int id, User requestor, ReservedObject reservedObject,
			List<ReservationContext> reservationContexts, Date from, Date to,
			String description) {
		super();
		this.id = id;
		this.requestor = requestor;
		this.reservedObject = reservedObject;
		this.reservationContexts = reservationContexts;
		this.from = from;
		this.to = to;
		this.description = description;
	}

	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public User getRequestor() {
		return requestor;
	}
	public void setRequestor(User requestor) {
		this.requestor = requestor;
	}
	public ReservedObject getReservedObject() {
		return reservedObject;
	}
	public void setReservedObject(ReservedObject reservedObject) {
		this.reservedObject = reservedObject;
	}
	public List<ReservationContext> getReservationContexts() {
		return reservationContexts;
	}
	public void setReservationContexts(List<ReservationContext> reservationContexts) {
		this.reservationContexts = reservationContexts;
	}
	public Date getFrom() {
		return from;
	}
	public void setFrom(Date from) {
		this.from = from;
	}
	public Date getTo() {
		return to;
	}
	public void setTo(Date to) {
		this.to = to;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}	
}
